package Submarine;

import javax.swing.*;

/**
 * 战舰
 */
public class Battleship extends SeaObject {
    //命
    int life;
    int bsstate = World.NORMAL;

    public Battleship() {
        super(270, 124, 20, 66, 26);
        life = 5;
    }

    @Override
    public void move() {
        System.out.println("战舰来回移动...");
    }

    /**
     * 重写getImage()获取图片
     */
    public ImageIcon getImage() {
        if (bsstate == World.INVICIBLE) {
            return Images.battleship1;
        } else {
            return Images.battleship;
        }//返回战舰的图片
    }

    /**
     * -- 战舰扔雷 --
     */
    public Bomb shootBomb() {
        return new Bomb(this.x + 9, this.y - 12);
    }

    /**
     * 战舰坐标改变
     */
    public void moveL() {
        if(x>0)x -= speed;
    }

    public void moveR() {
        if(x<641)x += speed;
    }

    /**
     * 战舰获得生命
     */
    public void addLife(int num) {
        life += num;
    }

    /**
     * 战舰失去生命
     */
    public void decreLife(int num) {
        life -= num;
    }

    /**
     * 战舰生命
     */
    public int getLife() {
        return life;
    }
}
















